package sample.boot.metrics;

import javax.annotation.PostConstruct;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created on 2020/8/7
 */
@Component
public class MyMetrics {
	@Autowired
	private MeterRegistry meterRegistry;

	private Counter counter;

	@PostConstruct
	public void init() {
		counter = meterRegistry.counter("demo.counter");
	}

	public void foo() {
		counter.increment();
	}
}
